// 用户

import request from '@/utils/request'

// 登录
export const login = (data) => {
  return request({
    url: 'login',
    method: 'POST',
    data
  })
}

// 用户列表
export const users = (params) => {
  return request({
    url: 'users',
    method: 'GET',
    params
  })
}

// 添加用户
export const addUser = (data) => {
  return request({
    url: 'users',
    method: 'POST',
    data
  })
}

// 修改用户状态
export const editState = (data) => {
  return request({
    url: `users/${data.id}/state/${data.mg_state}`,
    method: 'PUT'
  })
}

// 根据id删除用户
export const delUser = (id) => {
  return request({
    url: `users/${id}`,
    method: 'DELETE'
  })
}

// 编辑用户
export const editUser = (data) => {
  return request({
    url: `users/${data.id}`,
    method: 'PUT',
    data
  })
}

// 根据id查询用户信息
export const lookUser = (id) => {
  return request({
    url: `users/${id}`,
    method: 'GET'
  })
}

// 给用户分配角色
export const assignRoles = (data) => {
  return request({
    url: `users/${data.id}/role`,
    method: 'PUT',
    data
  })
}
